package cnooc.energy.service.impl;


import cnooc.common.config.InfluxDbComUtil;
import cnooc.common.utils.DateUtils;
import cnooc.energy.domain.Equipment;
import cnooc.energy.mapper.EquipmentMapper;
import cnooc.energy.service.IEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备配置Service业务层处理
 *
 * @author 韩是非
 * @date 2023-11-28
 */
@Service
public class EquipmentServiceImpl implements IEquipmentService {
    @Autowired
    private EquipmentMapper equipmentMapper;
    @Autowired
    private InfluxDbComUtil influxDbComUtil;
    /**
     * 查询设备配置
     *
     * @param id 设备配置主键
     * @return 设备配置
     */
    @Override
    public Equipment selectEquipmentById(Long id) {
        return equipmentMapper.selectEquipmentById(id);
    }

    /**
     * 查询设备配置列表
     *
     * @param equipment 设备配置
     * @return 设备配置
     */
    @Override
    public List<Equipment> selectEquipmentList(Equipment equipment) {
        return equipmentMapper.selectEquipmentList(equipment);
    }

    /**
     * 新增设备配置
     *
     * @param equipment 设备配置
     * @return 结果
     */
    @Override
    public int insertEquipment(Equipment equipment) {
        equipment.setCreateTime(DateUtils.getNowDate());
        return equipmentMapper.insertEquipment(equipment);
    }

    /**
     * 修改设备配置
     *
     * @param equipment 设备配置
     * @return 结果
     */
    @Override
    public int updateEquipment(Equipment equipment) {
        equipment.setUpdateTime(DateUtils.getNowDate());
        return equipmentMapper.updateEquipment(equipment);
    }

    /**
     * 批量删除设备配置
     *
     * @param ids 需要删除的设备配置主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentByIds(Long[] ids) {
        return equipmentMapper.deleteEquipmentByIds(ids);
    }

    /**
     * 删除设备配置信息
     *
     * @param id 设备配置主键
     * @return 结果
     */
    @Override
    public int deleteEquipmentById(Long id) {
        return equipmentMapper.deleteEquipmentById(id);
    }

    @Override
    public Object deviceWaring() {
        return equipmentMapper.deviceWaring();
    }

}
